<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('strator_auth_tokens', function (Blueprint $table) {
            $table->id();

            $table->unsignedInteger('strator_id')->index()->comment('管理员id');
            $table->char('client_type',32)->index()->comment('登录客户端类型');
            $table->string('token')->unique()->comment('token');
            $table->dateTime('expires_at')->nullable()->comment('过期时间');
            $table->dateTime('last_used_at')->nullable()->comment('最后一次使用时间');

            $table->timestamps();
            $table->softDeletes();
        });

        \DB::statement("ALTER TABLE `strator_auth_tokens` comment '管理员登录token表'");
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('strator_auth_tokens');
    }
};
